//
//  AboutUsViewController.m
//  Btpin
//
//  Created by Vic on 2020/2/3.
//  Copyright © 2020 Vic. All rights reserved.
//

#import "AboutUsViewController.h"
#import "LYSettingCell.h"
//#import "PrivacyPolicyViewController.h"
#import "GeneralWebViewViewController.h"

@interface AboutUsViewController ()<UITableViewDelegate, UITableViewDataSource>
{
    NSArray *dataArray;
    
    UITableView *cTableView;
}
@end

@implementation AboutUsViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"关于我们";
    
    NSString *versoinStr = [UIToolsControl getVersion];
    dataArray = @[@{@"name":@"服务协议", @"detail":@""},
                  @{@"name":@"隐私政策", @"detail":@""},
                  @{@"name":@"客服电话", @"detail":@"010 - 84949711"},
                  @{@"name":@"微信公众号", @"detail":@"比特聘"},
                  @{@"name":@"当前版本", @"detail":versoinStr}];
    
    [self initUI];
}
- (void)initUI {
    cTableView = [UIToolsControl initTableViewWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT-HeightOfStatusBarAndNavigationBar-SIMEmojKeyBoardkBottomNOSafeArea_Height) target:self style:UITableViewStyleGrouped];
    cTableView.showsVerticalScrollIndicator = NO;
    cTableView.estimatedRowHeight = 0;
    cTableView.estimatedSectionHeaderHeight = 0;
    cTableView.estimatedSectionFooterHeight = 0;
    cTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    cTableView.sectionIndexBackgroundColor = COLOR_OF_CLEAR;
    [cTableView registerClass:[LYSettingCell class] forCellReuseIdentifier:kCellIdentifier_LYSettingCell];
    [self.view addSubview:cTableView];
    
    UIView *headerView = [UIToolsControl initViewWithFrame:CGRectMake(0, 0, WIDTH, ScalePS(90)) backgroundColor:COLOR_OF_WHITE];
    UIImageView *logoImgView = [UIToolsControl initImageViewWithFrame:CGRectMake((WIDTH-ScalePS(60))*0.5, ScalePS(15), ScalePS(60), ScalePS(60)) imageName:@"logo_icon"];
    [headerView addSubview:logoImgView];
    
    cTableView.tableHeaderView = headerView;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    LYSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_LYSettingCell forIndexPath:indexPath];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    NSDictionary *dic = dataArray[indexPath.row];
    [cell setTitle:dic[@"name"] detail:dic[@"detail"]];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    switch (indexPath.row) {
        case 0: {
            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
            GWVC.showType = GeneralWebViewTypeOfResignAgreement;
            GWVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:GWVC animated:YES];
        } break;
        case 1: {
            GeneralWebViewViewController *GWVC = [[GeneralWebViewViewController alloc] init];
            GWVC.showType = GeneralWebViewTypeOfPrivacyPolicy;
            GWVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:GWVC animated:YES];
        } break;
        case 2: {
            [self callTel:@"01084949711"];
        } break;
        case 3: {
            UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
            pasteboard.string = @"比特聘";
            SVPHUDSuccess(@"复制成功，微信搜索公众号'比特聘'");
        } break;
        default:
            break;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.00001;
}

@end
